<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <%--<script src="${pageContext.request.contextPath}/js/prototype.js" type="text/javascript"></script>--%>
    <%--<script src="${pageContext.request.contextPath}/js/effects.js" type="text/javascript"></script>--%>
    <%--<script type="text/javascript" src="${pageContext.request.contextPath}/js/validation.js"></script>--%>
    <link rel="stylesheet" type="text/css" href="http://www.java1234.com/jquery-easyui-1.3.3/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="http://www.java1234.com/jquery-easyui-1.3.3/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="http://www.java1234.com/jquery-easyui-1.3.3/demo/demo.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="http://www.java1234.com/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="http://www.java1234.com/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>

        <script type="text/javascript">

        function setActiveStyleSheet(title) {
            var i, a, main;
            for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
                if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
                    a.disabled = true;
                    if(a.getAttribute("title") == title) a.disabled = false;
                }
            }
        }
    </script>
    <link title="style1" rel="stylesheet" href="${pageContext.request.contextPath}/css/add_course.css" type="text/css" />
        <%@ include file= "index_nav.jsp" %>
</head>
<body>


<div class="form_content">
    <div id="test">

        <fieldset>
            <legend>录入教师</legend>

            <div class="form-row">
                <div class="field-label"><label for="tname">教师姓名</label>:</div>
                <div class="field-widget"><input name="tname" id="tname" class="required" title="Enter your name"/>
                </div>
            </div>

            <div class="form-row">
                <div class="field-label"><label for="tid">教师号</label>:</div>
                <div class="field-widget"><input name="tid" id="tid" class="required validate-email"
                                                 title="Enter your name"/></div>
            </div>


            <div class="form-row">
                <div class="field-label"><label for="ttel">联系方式</label>:</div>
                <div class="field-widget"><input name="ttel" id="ttel" class="required validate-password"
                                                 title="Enter a password greater than 6 characters"/></div>
            </div>


        </fieldset>

        <input type="submit" class="submit" value="提交"/> <input class="reset" type="button" value="重置"
                                                                onclick="valid.reset(); return false"/>
    </div>
</div>
    <script type="text/javascript">
        (function () {
            function sendReq() {
                var msg={};
                var sname=$('#sname').val();
                var sid=$('#sid').val();
                var sex=$('#sex option:selected').val();
                var major_id=$('#major option:selected').attr('major_id');
                var max_num=$('#max_num').val();
                var birthday=$('#birthday').val();
                msg.sname=sname;
                msg.sid=sid;
                msg.sex=sex;
                msg.major_id=major_id;
                msg.max_num=max_num;
                msg.birthday=birthday;
                console.log(msg);
                $.ajax({
                    url:'${pageContext.request.contextPath}/admin/add_student',
                    data:msg,
                    dataType : "text",
                    success:function (data) {
                        if(data=="success"){
                            alert("添加成功!")
                        }
                        else {
                            alert('添加失败!')
                        }
                    }
                })
            }
            $('.submit').click(sendReq);
        })()
        /*function formCallback(result, form) {
            window.status = "valiation callback for form '" + form.id + "': result = " + result;
        }
        
        var valid = new Validation('test', {immediate : true, onFormValidate : formCallback});
        Validation.addAllThese([
            ['validate-password', '> 6 characters', {
                minLength : 7,
                notOneOf : ['password','PASSWORD','1234567','0123456'],
                notEqualToField : 'field1'
            }],
            ['validate-password-confirm', 'please try again.', {
                equalToField : 'field8'
            }]
        ]);*/
    </script>

</body>
</html>